window.rootPath = (function (src) {
	src = document.currentScript
		? document.currentScript.src
		: document.scripts[document.scripts.length - 1].src;
	return src.substring(0, src.lastIndexOf("/") + 1);
})();
if (typeof jQuery === 'undefined') window.$ = window.jQuery = layui.$;
window.form = layui.form, window.layer = layui.layer, window.laydate = layui.laydate,window.table = layui.table;

if (typeof $ == "undefined") {
	window.jQuery = layui.jquery;
	window.$ = layui.jquery;
}
if (typeof moduleInit == "undefined") {
	window.moduleInit = [];
}
var module = {};
if (moduleInit.length > 0) {
	for (var i = 0; i < moduleInit.length; i++) {
		module[moduleInit[i]] = moduleInit[i];
	}
}
layui.config({
	base: rootPath + "module/",
	version: "2.7.6"
}).extend(module).use(moduleInit, function () {
	if (typeof gouguInit === 'function') {
		gouguInit();
	}
});


/**
 *
 * @param id
 * 上传图片
 */
function uploadImgs(id='') {
	let taht =$(id);
	let upIconId=id.replace('#','')+'fileUpLoad'
	let limt=taht.attr('limit')||1;
	let inputData=$(id).val();
	let imgData=[];
	if (inputData){
		imgData=inputData.split(',');
	}
	if (imgData){
		var imgtp='';
		for (var i=0;i<imgData.length;i++){
			imgtp+="<div class='upImgDiv' ><img onclick='tipImgByclass(this)' src='"+imgData[i]+"'/> <a data-data='"+imgData[i]+"' class='closeUpimg' onclick=\"delUpimg(this,'"+id+"')\">x</a></div>";
		}
		$(taht).before(imgtp)
	}
	$(taht).after('<a class="uploadimage" id="'+upIconId+'"></a>')
	if (imgData.length>=limt){
		$('#'+upIconId).css('display','none');
	}else {
		$('#'+upIconId).css('display','');
	}
	layui.upload.render({
		elem:"#"+upIconId,
		url: "/api/index/upload",
		done: function (res) {
			layer.msg(res.msg);
			if (res.code == 0) {
				//上传成功
				// $('#demo1 input').attr('value', res.data.filepath);
				// $('#demo1 img').attr('src', res.data.filepath);
				let inputData=$(id).val();
				let imgData=[];
				if (inputData){
					imgData=inputData.split(',');
				}
				$(taht).before("<div class='upImgDiv' ><img onclick='tipImgByclass(this)' src='"+res.data.filepath+"'/> <a data-data='"+res.data.filepath+"' class='closeUpimg' onclick=\"delUpimg(this,'"+id+"')\" >x</a></div>")
				imgData.push(res.data.filepath)
				$(id).val(imgData.join(','))
				if (imgData.length>=limt){
					$('#'+upIconId).css('display','none');
				}else {
					$('#'+upIconId).css('display','');
				}
			}
		}
	});
}

/**
 * 删除上传图片
 * @param obj
 * @param id
 */
function delUpimg(obj,id) {
	let src=$(obj).attr('data-data')
	let limt=$(id).attr('limit')||1;
	let upIconId=id.replace('#','')+'fileUpLoad'
	let inputData=$(id).val();
	let imgData=[];
	if (inputData){
		imgData=inputData.split(',');
	}
	imgData=imgData.filter(function (item) {
		return item != src
	})
	$(obj).parent().remove()
	if (imgData.length>=limt){
		$('#'+upIconId).css('display','none');
	}else {
		$('#'+upIconId).css('display','');
	}
	$(id).val(imgData.join(','))
}

/**
 * 图片预览
 * @param obj
 */
function tipImg(obj){
	var imgArry = [];
	var id = $(obj).attr('id');
	$("#"+id).find("img").each(function(){
		imgArry.push({"src": $(this).attr("src")})
	})
	layer.photos({
		photos: {
			"title": "", //相册标题
			"start": 0, //初始显示的图片序号，默认0
			"data": imgArry
		} //格式见API文档手册页
		,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
	});
}
function tipImgByclass(obj){
	var imgArry = [];
	var id = $(obj).parent().attr('class');
	$("."+id).find("img").each(function(){
		imgArry.push({"src": $(this).attr("src")})
	})
	layer.photos({
		photos: {
			"title": "", //相册标题
			"start": 0, //初始显示的图片序号，默认0
			"data": imgArry
		} //格式见API文档手册页
		,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
	});
}
function uploadFiles(id='') {
	let taht =$(id);
	let upIconId=id.replace('#','')+'fileUpLoad'
	let limt=taht.attr('limit')||1;
	let inputData=$(id).val();
	let canDo=taht.attr('data-canDo')||'1';
	let thisId="#"+upIconId;
	let hideClass='';
	if (canDo==='0'){
		thisId='';
		hideClass='hideBan'
	}
	let imgData=[];
	if (inputData){
		imgData=inputData.split(',');
		$.ajax({
			url:'/api/index/getFiles',
			type:'post',
			dataType:'json',
			data:{filepaths:inputData},
			success:function (res) {
				let resDatas=res.data;
				if (resDatas){
					var imgtp='';
					for (var i=0;i<resDatas.length;i++){
						let showData=resDatas[i];
						// if (showData.fileext=='docx'||showData.fileext=='doc'||showData.fileext=='xlsx'||showData.fileext=='xls'){
						imgtp+="  <div class='upImgDiv' >\n" +
							"                        <a class='up_fileName'  href='javascript:'> "+showData.name+" </a>\n" +
							"                        <div class='file_btn_ban'>\n" +
							"                            <a data-data='"+showData.filepath+"'  class='closeUpimg "+hideClass+"' onclick=\"delUpFiles(this,'"+id+"')\" >删除</a>\n" +
							"                            <a data-data='' target='_blank' class='editUpimg' href='"+showData.viewPath+"' >预览</a>\n" +
							"                            <a data-data=''  href='"+showData.filepath+"' download='"+showData.name+"' class='downloadUpimg'  >下载</a>\n" +
							"                        </div>\n" +
							"                    </div>";
						// imgtp+="<div class='upImgDiv' ><i class='file-icon iconfont icon-sucaiziyuan'></i>
						// <a class='up_fileName' target='_blank' href='"+showData.filepath+"'>"+showData.name+"
						// </a><a data-data='"+showData.filepath+"' class='closeUpimg' onclick=\"delUpimg(this,'"+id+"')\">x</a></div>";
						// }else {
						// 	imgtp+="<div class='upImgDiv' ><i class='file-icon iconfont icon-sucaiziyuan'></i><a class='up_fileName' target='_blank' href='"+showData.filepath+"'>"+showData.name+" </a><a data-data='"+showData.filepath+"' class='closeUpimg' onclick=\"delUpimg(this,'"+id+"')\">x</a></div>";
						// }
					}
					$(taht).before(imgtp)
				}
			}
		})
	}


	$(taht).after('<a class="uploadimage " disabled="true" id="'+upIconId+'"></a>')
	if (imgData.length>=limt){
		$('#'+upIconId).css('display','none');
	}else {
		$('#'+upIconId).css('display','');
	}

	layui.upload.render({
		elem:thisId,
		accept:'file',
		url: "/api/index/upload",
		done: function (res) {
			layer.msg(res.msg);
			if (res.code == 0) {
				//上传成功
				// $('#demo1 input').attr('value', res.data.filepath);
				// $('#demo1 img').attr('src', res.data.filepath);
				let inputData=$(id).val();
				let imgData=[];
				if (inputData){
					imgData=inputData.split(',');
				}
				$(taht).before("  <div class='upImgDiv' >\n" +
					"                        <a class='up_fileName'  href='javascript:'> "+res.data.name+"</a>\n" +
					"                        <div class=\"file_btn_ban\">\n" +
					"                            <a data-data='"+res.data.filepath+"' class='closeUpimg' onclick=\"delUpFiles(this,'"+id+"')\" >删除</a>\n" +
					"                            <a data-data='' target='_blank' class='editUpimg' href='"+res.data.viewPath+"'  >预览</a>\n" +
					"                            <a data-data='' target='_blank' href='"+res.data.filepath+"'  download='"+res.data.name+"' class='downloadUpimg'  >下载</a>\n" +
					"                        </div>\n" +
					"                    </div>")
				// $(taht).before("<div class='upImgDiv' ><i class='file-icon iconfont icon-sucaiziyuan'></i><a class='up_fileName' target='_blank' href='"+res.data.filepath+"'> "+res.data.name+"</a> <a data-data='"+res.data.filepath+"' class='closeUpimg' onclick=\"delUpimg(this,'"+id+"')\" >x</a></div>")
				imgData.push(res.data.filepath)
				$(id).val(imgData.join(','))
				if (imgData.length>=limt){
					$('#'+upIconId).css('display','none');
				}else {
					$('#'+upIconId).css('display','');
				}
			}
		}
	});
}
// function uploadFiles(id='') {
// 	let taht =$(id);
// 	let upIconId=id.replace('#','')+'fileUpLoad'
// 	let limt=taht.attr('limit')||1;
// 	let inputData=$(id).val();
// 	let imgData=[];
// 	if (inputData){
// 		imgData=inputData.split(',');
// 		$.ajax({
// 			url:'/api/index/getFiles',
// 			type:'post',
// 			dataType:'json',
// 			data:{filepaths:inputData},
// 			success:function (res) {
// 				let resDatas=res.data;
// 				if (resDatas){
// 					var imgtp='';
// 					for (var i=0;i<resDatas.length;i++){
// 						let showData=resDatas[i];
// 						// if (showData.fileext=='docx'||showData.fileext=='doc'||showData.fileext=='xlsx'||showData.fileext=='xls'){
// 						imgtp+="  <div class='upImgDiv' >\n" +
// 							"                        <a class='up_fileName'  href='javascript:'> "+showData.name+" </a>\n" +
// 							"                        <div class='file_btn_ban'>\n" +
// 							"                            <a data-data='"+showData.filepath+"' class='closeUpimg' onclick=\"delUpFiles(this,'"+id+"')\" >删除</a>\n" +
// 							"                            <a data-data='' target='_blank' class='editUpimg' href='"+showData.viewPath+"' >预览</a>\n" +
// 							"                            <a data-data=''  href='"+showData.filepath+"' download='"+showData.name+"' class='downloadUpimg'  >下载</a>\n" +
// 							"                        </div>\n" +
// 							"                    </div>";
// 						// imgtp+="<div class='upImgDiv' ><i class='file-icon iconfont icon-sucaiziyuan'></i>
// 						// <a class='up_fileName' target='_blank' href='"+showData.filepath+"'>"+showData.name+"
// 						// </a><a data-data='"+showData.filepath+"' class='closeUpimg' onclick=\"delUpimg(this,'"+id+"')\">x</a></div>";
// 						// }else {
// 						// 	imgtp+="<div class='upImgDiv' ><i class='file-icon iconfont icon-sucaiziyuan'></i><a class='up_fileName' target='_blank' href='"+showData.filepath+"'>"+showData.name+" </a><a data-data='"+showData.filepath+"' class='closeUpimg' onclick=\"delUpimg(this,'"+id+"')\">x</a></div>";
// 						// }
// 					}
// 					$(taht).before(imgtp)
// 				}
// 			}
// 		})
// 	}
//
// 	$(taht).after('<a class="uploadimage " id="'+upIconId+'"></a>')
// 	if (imgData.length>=limt){
// 		$('#'+upIconId).css('display','none');
// 	}else {
// 		$('#'+upIconId).css('display','');
// 	}
// 	layui.upload.render({
// 		elem:"#"+upIconId,
// 		accept:'file',
// 		url: "/api/index/upload",
// 		done: function (res) {
// 			layer.msg(res.msg);
// 			if (res.code == 0) {
// 				//上传成功
// 				// $('#demo1 input').attr('value', res.data.filepath);
// 				// $('#demo1 img').attr('src', res.data.filepath);
// 				let inputData=$(id).val();
// 				let imgData=[];
// 				if (inputData){
// 					imgData=inputData.split(',');
// 				}
// 				$(taht).before("  <div class='upImgDiv' >\n" +
// 					"                        <a class='up_fileName'  href='javascript:'> "+res.data.name+"</a>\n" +
// 					"                        <div class=\"file_btn_ban\">\n" +
// 					"                            <a data-data='"+res.data.filepath+"' class='closeUpimg' onclick=\"delUpFiles(this,'"+id+"')\" >删除</a>\n" +
// 					"                            <a data-data='' target='_blank' class='editUpimg' href='"+res.data.viewPath+"'  >预览</a>\n" +
// 					"                            <a data-data='' target='_blank' href='"+res.data.filepath+"'  download='"+res.data.name+"' class='downloadUpimg'  >下载</a>\n" +
// 					"                        </div>\n" +
// 					"                    </div>")
// 				// $(taht).before("<div class='upImgDiv' ><i class='file-icon iconfont icon-sucaiziyuan'></i><a class='up_fileName' target='_blank' href='"+res.data.filepath+"'> "+res.data.name+"</a> <a data-data='"+res.data.filepath+"' class='closeUpimg' onclick=\"delUpimg(this,'"+id+"')\" >x</a></div>")
// 				imgData.push(res.data.filepath)
// 				$(id).val(imgData.join(','))
// 				if (imgData.length>=limt){
// 					$('#'+upIconId).css('display','none');
// 				}else {
// 					$('#'+upIconId).css('display','');
// 				}
// 			}
// 		}
// 	});
// }


function uploadImg(id='') {
    let taht =$(id);
    let limt=taht.attr('limit')||1;
    let inputData=$(id).val();
    let imgData=[];
    if (inputData){
        imgData=inputData.split(',');
    }
    if (imgData){
        var imgtp='';
        for (var i=0;i<imgData.length;i++){
            imgtp+="<div class='upImgDiv' ><img onclick='tipImgByclass(this)' src='"+imgData[i]+"'/> <a data-data='"+imgData[i]+"' class='closeUpimg' onclick=\"delUpimg(this,'"+id+"')\">x</a></div>";
        }
        $(taht).before(imgtp)
    }
    $(taht).after('<a class="uploadimage" id="imgUpLoad"></a>')
    layui.upload.render({
        elem:"#imgUpLoad",
        url: "/api/index/upload",
        done: function (res) {
            layer.msg(res.msg);
            if (res.code == 0) {
                //上传成功
                // $('#demo1 input').attr('value', res.data.filepath);
                // $('#demo1 img').attr('src', res.data.filepath);
                let inputData=$(id).val();
                let imgData=[];
                if (inputData){
                    imgData=inputData.split(',');
                }
                $(taht).before("<div class='upImgDiv' ><img onclick='tipImgByclass(this)' src='"+res.data.filepath+"'/> <a data-data='"+res.data.filepath+"' class='closeUpimg' onclick=\"delUpimg(this,'"+id+"')\" >删除</a></div>")
                imgData.push(res.data.filepath)
                $(id).val(imgData.join(','))
                if (imgData.length>=limt){
                    $('#imgUpLoad').css('display','none');
                }else {
                    $('#imgUpLoad').css('display','');
                }
            }
        }
    });
}

function uploadFilesBuyAny(id='',table='',dataId='') {
	let taht =$(id);
	let upIconId=id.replace('#','')+'fileUpLoad'
	let limt=taht.attr('limit')||1;
	let inputData=$(id).val();
	let imgData=[];
	if (inputData){
		imgData=inputData.split(',');
		$.ajax({
			url:'/api/index/getFiles',
			type:'post',
			dataType:'json',
			data:{filepaths:inputData},
			success:function (res) {
				let resDatas=res.data;
				if (resDatas){
					var imgtp='';
					for (var i=0;i<resDatas.length;i++){
						let showData=resDatas[i];
						// if (showData.fileext=='docx'||showData.fileext=='doc'||showData.fileext=='xlsx'||showData.fileext=='xls'){
						imgtp+="  <div class='upImgDiv' >\n" +
							"                        <a class='up_fileName'  href='javascript:'> "+showData.name+" </a>\n" +
							"                        <div class='file_btn_ban'>\n" +
							"                            <a data-data='"+showData.filepath+"' class='closeUpimg' onclick=\"delUpFiles(this,'"+id+"')\" >删除</a>\n" +
							"                            <a data-data='' target='_blank' class='editUpimg' href='"+showData.viewPath+"' >预览</a>\n" +
							"                            <a data-data=''  href='"+showData.filepath+"' download='"+showData.name+"' class='downloadUpimg'  >下载</a>\n" +
							"                        </div>\n" +
							"                    </div>";
						// imgtp+="<div class='upImgDiv' ><i class='file-icon iconfont icon-sucaiziyuan'></i>
						// <a class='up_fileName' target='_blank' href='"+showData.filepath+"'>"+showData.name+"
						// </a><a data-data='"+showData.filepath+"' class='closeUpimg' onclick=\"delUpimg(this,'"+id+"')\">x</a></div>";
						// }else {
						// 	imgtp+="<div class='upImgDiv' ><i class='file-icon iconfont icon-sucaiziyuan'></i><a class='up_fileName' target='_blank' href='"+showData.filepath+"'>"+showData.name+" </a><a data-data='"+showData.filepath+"' class='closeUpimg' onclick=\"delUpimg(this,'"+id+"')\">x</a></div>";
						// }
					}
					$(taht).before(imgtp)
				}
			}
		})
	}

	$(taht).after('<a class="uploadimage " id="'+upIconId+'"></a>')
	if (imgData.length>=limt){
		$('#'+upIconId).css('display','none');
	}else {
		$('#'+upIconId).css('display','');
	}
	layui.upload.render({
		elem:"#"+upIconId,
		accept:'file',
		url: "/api/index/upload",
		done: function (res) {
			layer.msg(res.msg);
			if (res.code == 0) {
				//上传成功
				// $('#demo1 input').attr('value', res.data.filepath);
				// $('#demo1 img').attr('src', res.data.filepath);
				let inputData=$(id).val();
				let imgData=[];
				if (inputData){
					imgData=inputData.split(',');
				}
				$(taht).before("  <div class='upImgDiv' >\n" +
					"                        <a class='up_fileName'  href='javascript:'> "+res.data.name+"</a>\n" +
					"                        <div class=\"file_btn_ban\">\n" +
					"                            <a data-data='"+res.data.filepath+"' class='closeUpimg' onclick=\"delUpFiles(this,'"+id+"')\" >删除</a>\n" +
					"                            <a data-data='' target='_blank' class='editUpimg' href='"+res.data.viewPath+"'  >预览</a>\n" +
					"                            <a data-data='' target='_blank' href='"+res.data.filepath+"'  download='"+res.data.name+"' class='downloadUpimg'  >下载</a>\n" +
					"                        </div>\n" +
					"                    </div>")
				// $(taht).before("<div class='upImgDiv' ><i class='file-icon iconfont icon-sucaiziyuan'></i><a class='up_fileName' target='_blank' href='"+res.data.filepath+"'> "+res.data.name+"</a> <a data-data='"+res.data.filepath+"' class='closeUpimg' onclick=\"delUpimg(this,'"+id+"')\" >x</a></div>")
				imgData.push(res.data.filepath)
				$(id).val(imgData.join(','))
				if (table!=''&&dataId!=''){
					let field=$(id).attr('name');
					let param={
						table:table,
						dataId:dataId,
						field:field,
						val:imgData.join(',')
					}
					httpRequest('/api/index/upFiled',param,function (res) {

					},false)
				}
				if (imgData.length>=limt){
					$('#'+upIconId).css('display','none');
				}else {
					$('#'+upIconId).css('display','');
				}
			}
		}
	});
}
function delUpFiles(obj,id) {
	let src=$(obj).attr('data-data')
	let limt=$(id).attr('limit')||1;
	let upIconId=id.replace('#','')+'fileUpLoad'
	let inputData=$(id).val();
	let imgData=[];
	if (inputData){
		imgData=inputData.split(',');
	}
	imgData=imgData.filter(function (item) {
		if (!src.includes(item)){
			return item;
		}
	})
	$(obj).parent().parent().remove()
	if (imgData.length>=limt){
		$('#'+upIconId).css('display','none');
	}else {
		$('#'+upIconId).css('display','');
	}
	$(id).val(imgData.join(','))
}
/**
 * 输入框小数取值
 * @param obj
 * @param num
 */
function digitalFiltering(obj,num){
	obj.value = obj.value.replace(/[^-?\d.]/g,"");//清除"数字"和"."以外的字符
	// obj.value = obj.value.replace(/^\./g,"");//验证第一个字符是数字而不是字符
	obj.value = obj.value.replace(/\.{2,}/g,".");//只保留第一个.清除多余的
	obj.value = obj.value.replace(/^-{2,}/g,"-");//只保留第一个-清除多余的
	obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
	obj.value = obj.value.replace(new RegExp(`^(\\-)*(\\d+)\\.(\\d{${num}}).*$`),  '$1$2.$3');//只能输入两个小数
}
let layTip='';
$(function () {
	$("#tip_modal").on('click', '[data-modal]', function () {
		var that = this;
		var loadingIndex = layer.load();
		$.get($(that).attr('data-modal'),{},function (res) {
			layer.close(loadingIndex)
			var index = layer.open({
				type: 1,
				btn: false,
				area: ["1100px",'600px'],
				id:'lay_modal_id',
				content: res,
				title: $(that).attr('data-title') || $(that).text() || '编辑',
				success: function (dom, index) {
					layTip=index;
					$(dom).find('[data-close]').off('click').on('click', function () {
						if ($(that).attr('data-confirm')) return $.msg.confirm($(that).attr('data-confirm'), function (_index) {
							layer.close(_index), layer.close(index);
						}), false;
						layer.close(index);

					});
				},
				end:function () {
					layer.close(index);
				}
			});
		})

	});

	//点击非下拉区域隐藏
	$(document).bind('click', function (e) {
		let target = $(".stateBlock");
		let obj = $(".warehouse");
		if(!target.is(e.target) && target.has(e.target).length ===0 && !obj.is(e.target) && obj.has(e.target).length ===0){
			target.hide();
		}
	});
	$("#chooseWareHouse").on('click',function() {
		$(".stateBlock").show();
	})
	$(".warehouse .stateBlock li").on('click',function() {
		let id = $(this).data('id');
		let name=$(this).data('sname')||'warehouse_id';

		$("select[name='"+name+"[]']").each(function() {
			let obj = $(this);
			obj.val(id);
		});
		layui.form.render();
		$(".stateBlock").hide();
	})

	$(".btn_side").on('click',function () {
		let url=$(this).attr('data-url')
		// console.log('url',url)
	layui.tool.side(url)
	})
	$(".btn_box").on('click',function () {
		let url=$(this).attr('data-url')
		let title=$(this).attr('data-title')||'内容'
		let width=$(this).attr('data-width')||'800'
		let height=$(this).attr('data-height')||'600'
		// // console.log('url',url)
		// layui.tool.box(url,title,width,height)
		let that = this;
		if (that.loading == true) {
			return false;
		}
		that.loading = true;
			layer.open({
				type: 2,
				title: title,
				content: url,
				area: [width + 'px', height + 'px'],
				maxmin: true,
				end: function () {
					if (layui.pageTable && layui.pageTable.resize) {
						layui.pageTable.resize();
					}
				},
				success: function (obj, index) {
					var btn = '<div data-index="' + index + '" class="express-close" style="display:none;" title="关闭">关闭</div>';
					obj.append(btn);
					mxIndex=index;
					that.loading = false;
					obj.on('click', '.express-close', function () {
						layer.close(index);
					})
				}
			})

	})

});

function formatTimeTwo(number, format) {
	if (!format) {
		format = 'Y-M-D h:m';
	}
	var formateArr = ['Y', 'M', 'D', 'h', 'm', 's'];
	var returnArr = [];
	var date = new Date(number * 1000);
	returnArr.push(date.getFullYear());
	returnArr.push(formatNumber(date.getMonth() + 1));
	returnArr.push(formatNumber(date.getDate()));
	returnArr.push(formatNumber(date.getHours()));
	returnArr.push(formatNumber(date.getMinutes()));
	returnArr.push(formatNumber(date.getSeconds()));
	for (var i in returnArr) {
		format = format.replace(formateArr[i], returnArr[i]);
	}
	return format;
}
/**
 * 自动补全
 */
function formatNumber(n) {
	n = n.toString();
	return n[1] ? n : '0' + n;
}
function httpRequest(url,data,callback,msg=true) {

	var loadId= layui.layer.load()
	$.ajax({
		url:url,
		type:'post',
		dataType:'json',
		data:data,
		success:function (res) {
			layui.layer.close(loadId)
			if (msg){
				layer.msg(res.msg)
			}

			if (callback && typeof callback === 'function') {
				callback(res);
			}

		},
		error(e){

			layer.msg('网络错误,请稍后重试')
			layui.layer.close(loadId)
		}
	})
}

function boxModel(url,title='内容',width=800,height=600) {
	// // console.log('url',url)
	// layui.tool.box(url,title,width,height)
	let that = this;
	if (that.loading == true) {
		return false;
	}
	that.loading = true;
	layer.open({
		type: 2,
		title: title,
		content: url,
		area: [width + 'px', height + 'px'],
		maxmin: true,
		end: function () {
			if (layui.pageTable && layui.pageTable.resize) {
				layui.pageTable.resize();
			}
		},
		success: function (obj, index) {
			var btn = '<div data-index="' + index + '" class="express-close" style="display:none;" title="关闭">关闭</div>';
			obj.append(btn);
			mxIndex=index;
			that.loading = false;
			obj.on('click', '.express-close', function () {
				layer.close(index);
			})
		}
	})
}
